import BaseMonsterSkill from "./BaseMonsterSkill";
import IBaseMonsterSkill from "./IBaseMonsterSkill";
import MonsterScript from "../../../component/MonsterScript";





export default class JumpMoveSkill extends BaseMonsterSkill implements IBaseMonsterSkill {





    exec() {
        // console.log("JumpMoveSkill exec")
        this._target.setSkipMove(true);
        if (this._isSkilling === true) {
            if ((Laya.Browser.now() - this._preExecTime) > this._durationTime) {
                this._isSkilling = false;
                this.resetTime();
            }
        }
        else {
            if (this.canExec()) {
                // console.log("STUNING...")
                this._isSkilling = true;
                // this._target.sp3d.transform.position = this._target.getMovePos();
                this._target.sp3d.transform.position.cloneTo(this._target.customMove);
                Laya.Tween.to(this._target.customMove, {
                    x: this._target.getMovePos().x, y: 0, z: this._target.getMovePos().z
                }, 1000, null, Laya.Handler.create(this, this.comp));

                this._preExecTime = Laya.Browser.now();
            }
        }

    }

    reset() {
        this._target.setSkipMove(false);
        super.reset();
    }

    comp() {
        // console.log("compleate..")
        if ((this._target.customMove.x===this._target.movePos[this._target.movePos.length-1].x)&&(this._target.customMove.z===this._target.movePos[this._target.movePos.length-1].z)) {
            this._target.arrive();
        }
    }


}